home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow / DVD / DVDSample / dialogs.cpp next >
Encoding:
C/C++ Source or Header  |  2001-10-31  |  39.0 KB  |  1,188 lines

  1. //------------------------------------------------------------------------------
  2. // File: Dialogs.cpp
  3. //
  4. // Desc: This file contains the implementation for the various dialog wrapper
  5. //       classes used in DvdSample.
  6. //
  7. // Copyright (c) 1999-2001 Microsoft Corporation. All rights reserved.
  8. //------------------------------------------------------------------------------
  9.  
  10. #include <dshow.h>
  11. #include <commctrl.h>
  12. #include <tchar.h>
  13. #include "resource.h"
  14. #include "DvdCore.h" // so we can directly access the IdvdInfo2 pointers
  15. #include "DvdSample.h"
  16. #include "Dialogs.h"
  17. #include "StringUtil.h"
  18.  
  19.  
  20.  
  21. //------------------------------------------------------------------------------
  22. // Name: struct LANGINFO
  23. // Desc: An easy way of getting the lang code from the DVD_SubpictureATR data
  24. //------------------------------------------------------------------------------
  25.  
  26. struct LANGINFO 
  27. {
  28.     WORD  wRes1 ;  // don't care, just skip 2 bytes
  29.     WORD  wLang ;  // lang code as a WORD value
  30.     WORD  wRes2 ;  // don't care, another 2 bytes
  31. };
  32.  
  33.  
  34.  
  35.  
  36. //------------------------------------------------------------------------------
  37. // CAboutDlg
  38. //------------------------------------------------------------------------------
  39.  
  40.  
  41. //------------------------------------------------------------------------------
  42. // Name: CAboutDlg::CAboutDlg()
  43. // Desc: This is the CAboutDialog constructor.  It initializes some variables
  44. //       that we'll need later.
  45. //------------------------------------------------------------------------------
  46.  
  47. CAboutDlg::CAboutDlg(HINSTANCE hInstance, HWND hWnd):
  48.     m_hInstance(hInstance), m_hWnd(hWnd)
  49. {
  50.     DbgLog((LOG_TRACE, 5, TEXT("CAboutDlg::CAboutDlg()"))) ;
  51. }
  52.  
  53.  
  54. //------------------------------------------------------------------------------
  55. // Name: CAboutDlg::~CAboutDlg()
  56. // Desc: This is the CAboutDialog destructor.
  57. //------------------------------------------------------------------------------
  58.  
  59. CAboutDlg::~CAboutDlg()
  60. {
  61.     DbgLog((LOG_TRACE, 5, TEXT("CAboutDlg::~CAboutDlg()"))) ;
  62. }
  63.  
  64.  
  65. //------------------------------------------------------------------------------
  66. // Name: CAboutDlg::DoModa()
  67. // Desc: This method creates the dialog box and handles its return value.
  68. //------------------------------------------------------------------------------
  69. bool CAboutDlg::DoModal()
  70. {
  71.     DbgLog((LOG_TRACE, 5, TEXT("CAboutDlg::DoModal()"))) ;
  72.  
  73.     int retVal;
  74.     retVal = DialogBoxParam(m_hInstance, MAKEINTRESOURCE(IDD_ABOUT), m_hWnd, 
  75.         (DLGPROC) CAboutDlg::AboutDlgProc, reinterpret_cast<LPARAM>(this));
  76.     if (TRUE == retVal)
  77.     {
  78.         return true;
  79.     }
  80.     else return false;
  81. }
  82.  
  83.  
  84. //------------------------------------------------------------------------------
  85. // Name: CAboutDlg::AboutDlgProc()
  86. // Desc: This method is the MessageProc for the CAboutDlg dialog box.  It handles
  87. //       all windows messages sent to the dialog window.
  88. //------------------------------------------------------------------------------
  89.  
  90. BOOL CALLBACK CAboutDlg::AboutDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  91. {
  92.     static CAboutDlg * pThis;
  93.  
  94.     switch (message)
  95.     {
  96.     case WM_INITDIALOG:
  97.         pThis = reinterpret_cast<CAboutDlg *>(lParam); // so we have a pointer to the calling object
  98.         return TRUE;
  99.  
  100.     case WM_COMMAND:
  101.         switch (LOWORD(wParam))
  102.         {
  103.         case IDOK:
  104.             EndDialog(hDlg, TRUE);
  105.             return TRUE;
  106.         }
  107.         break;
  108.     }
  109.     return FALSE;
  110. }
  111.  
  112.  
  113.  
  114.  
  115. //------------------------------------------------------------------------------
  116. // CSPLangDlg
  117. //------------------------------------------------------------------------------
  118.  
  119.  
  120. //------------------------------------------------------------------------------
  121. // Name: CSPLangDlg::CSPLangDlg()
  122. // Desc: This is the CSPLangDlg constructor.  It initializes some variables
  123. //       that we'll need later.
  124. //------------------------------------------------------------------------------
  125.  
  126. CSPLangDlg::CSPLangDlg(HINSTANCE hInstance, HWND hWnd):
  127.     m_hInstance(hInstance), m_hWnd(hWnd)
  128. {
  129.     DbgLog((LOG_TRACE, 5, TEXT("CSPLangDlg::CSPLangDlg()"))) ;
  130. }
  131.  
  132.  
  133. //------------------------------------------------------------------------------
  134. // Name: CSPLangDlg::~CSPLangDlg()
  135. // Desc: This is the CSPLangDlg destructor.
  136. //------------------------------------------------------------------------------
  137.  
  138. CSPLangDlg::~CSPLangDlg()
  139. {
  140.     DbgLog((LOG_TRACE, 5, TEXT("CSPLangDlg::~CSPLangDlg()"))) ;
  141. }
  142.  
  143.  
  144. //------------------------------------------------------------------------------
  145. // Name: CAboutDlg::DoModa()
  146. // Desc: This method creates the dialog box and handles its return value.
  147. //------------------------------------------------------------------------------
  148.  
  149. bool CSPLangDlg::DoModal()
  150. {
  151.     DbgLog((LOG_TRACE, 5, TEXT("CSPLangDlg::DoModal()"))) ;
  152.  
  153.     int retVal;
  154.     retVal = DialogBoxParam(m_hInstance, MAKEINTRESOURCE(IDD_SPDLG), m_hWnd, 
  155.         (DLGPROC) CSPLangDlg::SPDlgProc, reinterpret_cast<LPARAM>(this));
  156.     if (TRUE == retVal)
  157.     {
  158.         return true;
  159.     }
  160.     else return false;
  161. }
  162.  
  163.  
  164. //------------------------------------------------------------------------------
  165. // Name: CSPLangDlg::SPDlgProc()
  166. // Desc: This is the Dialog MessageProc for the subpicture language selection
  167. //       dialog.
  168. //------------------------------------------------------------------------------
  169.  
  170. BOOL CALLBACK CSPLangDlg::SPDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  171. {
  172.     static CSPLangDlg * pThis; 
  173.  
  174.     switch (message)
  175.     {
  176.  
  177.     case WM_INITDIALOG:
  178.         pThis = reinterpret_cast<CSPLangDlg *>(lParam); // get a pointer to the calling object
  179.         if (0 < pThis->MakeSPStreamList(hDlg, IDC_SPLANG))
  180.             return TRUE;
  181.         else
  182.         {
  183.              EndDialog(hDlg, FALSE);
  184.             return FALSE;
  185.         }
  186.  
  187.     case WM_COMMAND:
  188.         switch (LOWORD(wParam))
  189.         {
  190.         case IDOK:
  191.             {
  192.             HRESULT hr;
  193.  
  194.             // Set the SP state specified by the user
  195.             pThis->m_bSPOn = IsDlgButtonChecked(hDlg, IDC_SHOWSP) ;
  196.             hr = g_App.m_pDvdCore->m_pIDvdC2->SetSubpictureState(pThis->m_bSPOn, 0, NULL);
  197.             ASSERT(SUCCEEDED(hr)) ;
  198.  
  199.             // Set the SP stream specific by the user
  200.             LONG lStream;
  201.             lStream = SendDlgItemMessage(hDlg, IDC_SPLANG, CB_GETCURSEL, 
  202.                 static_cast<WPARAM>(0), static_cast<LPARAM>(0));
  203.             if (CB_ERR == lStream)
  204.                 DbgLog((LOG_ERROR, 1, 
  205.                 TEXT("WARNING: Couldn't get selected SP stream id (Error %d)"), lStream)) ;
  206.             else
  207.             {
  208.                 pThis->m_ulSPStream = lStream;
  209.                 hr = g_App.m_pDvdCore->m_pIDvdC2->SelectSubpictureStream(pThis->m_ulSPStream,
  210.                     0, NULL) ;
  211.                 ASSERT(SUCCEEDED(hr)) ;
  212.             }
  213.  
  214.             } // end of case brackets
  215.  
  216.             EndDialog(hDlg, TRUE);
  217.             return TRUE;
  218.  
  219.         case IDCANCEL:
  220.             EndDialog(hDlg, FALSE);
  221.             return TRUE;
  222.         }
  223.         break;
  224.     }
  225.     return FALSE;
  226. }
  227.  
  228.  
  229. //------------------------------------------------------------------------------
  230. // Name: CSPLangDlg::MakeSPStreamList()
  231. // Desc: This method will populate our dialog box and return the number of SP
  232. //       streams on this disc.  We do some extra work to get around LCID limitations
  233. //       on Win9x.
  234. //------------------------------------------------------------------------------
  235.  
  236. int CSPLangDlg::MakeSPStreamList(HWND hDlg, int iListID)
  237. {
  238.     DbgLog((LOG_TRACE, 5, TEXT("CSPLangDlg::MakeSPStreamList(0x%lx, %d)"), 
  239.         hDlg, iListID)) ;
  240.  
  241.     if (Uninitialized == g_App.m_pDvdCore->GetState())
  242.     {
  243.         DbgLog((LOG_ERROR, 0, TEXT("WARNING: DvdCore not initialized yet!"))) ;
  244.         return 0 ;
  245.     }
  246.  
  247.     // First clear the list box of all SP stream names
  248.     SendDlgItemMessage(hDlg, iListID, CB_RESETCONTENT, static_cast<WPARAM>(0), 
  249.         static_cast<LPARAM>(0)) ;
  250.  
  251.     // Find out how many SP streams are there and what's the current lang.
  252.     // This is our chance to find out if someone changed the SP lang through 
  253.     // DVD menu so that we can synch up our SP stream value now.
  254.     HRESULT hr = g_App.m_pDvdCore->m_pIDvdI2->GetCurrentSubpicture(&m_ulNumLang, &m_ulSPStream, 
  255.         &m_bSPOn) ;
  256.     if (FAILED(hr))
  257.     {
  258.         MessageBox(m_hWnd, TEXT("Not ready to find language information"), TEXT("Warning"), MB_OK) ;
  259.         return 0 ;
  260.     }
  261.     m_bSPOn = !m_bSPOn; // GetCurrentSubpicture returns IsDisabled, not IsOn
  262.  
  263.     LCID lcid;
  264.     TCHAR szLang[50];
  265.  
  266.     // Add all of the streams to the dialog box
  267.     for (ULONG ulStream = 0; ulStream < m_ulNumLang; ulStream++)
  268.     {
  269.         if (FAILED(g_App.m_pDvdCore->m_pIDvdI2->GetSubpictureLanguage(ulStream, &lcid)))
  270.         {
  271.             DbgLog((LOG_ERROR, 0, TEXT("WARNING: GetSubpictureLanguage Failed!"))) ;
  272.             return 0 ;
  273.         }
  274.  
  275.         if (0 == lcid || 0 == GetLocaleInfo(lcid, LOCALE_SLANGUAGE, 
  276.             szLang, sizeof(szLang)/sizeof(szLang[0]))) 
  277.         // 0 is the failure code for GetLocaleInfo
  278.         {
  279.             GetSPLang(ulStream, szLang, sizeof(szLang));
  280.         }
  281.  
  282.         // Add the language to the listbox
  283.         SendDlgItemMessage(hDlg, iListID, CB_ADDSTRING, static_cast<WPARAM>(0),
  284.             reinterpret_cast<LPARAM>(static_cast<PVOID>(szLang)));
  285.     }
  286.  
  287.     // set the current stream as the selected item
  288.     if (m_ulNumLang > 0) // if there are any streams
  289.     {
  290.         int iRes = SendDlgItemMessage(hDlg, iListID, CB_SETCURSEL, 
  291.             static_cast<WPARAM>(m_ulSPStream), static_cast<LPARAM>(0)) ;
  292.         if (CB_ERR == iRes)
  293.             DbgLog((LOG_ERROR, 1, 
  294.             TEXT("WARNING: Couldn't set %ld as selected SP stream id (Error %d)"),
  295.             m_ulSPStream, iRes)) ;
  296.     }
  297.  
  298.     // set the checkbox to refect the current SP state
  299.     CheckDlgButton(hDlg, IDC_SHOWSP, m_bSPOn ? BST_CHECKED : BST_UNCHECKED) ;
  300.  
  301.     return m_ulNumLang;
  302. }
  303.  
  304.  
  305. //------------------------------------------------------------------------------
  306. // Name: CSPLangDlg::GetSPLang()
  307. // Desc: This method gets the LCID language code and looks up the subpicture
  308. //       language based on that.  This is to get around problems with Win95 where
  309. //       not all LCID's are recognized.
  310. //------------------------------------------------------------------------------
  311.  
  312. bool CSPLangDlg::GetSPLang(ULONG ulStream, TCHAR * buffer, int iBufLen)
  313. {
  314.     DbgLog((LOG_TRACE, 5, TEXT("CSPLangDlg::GetSPLang()"))) ;
  315.  
  316.     DVD_SubpictureAttributes SPATR ;
  317.     LANGINFO * pSPATR = reinterpret_cast<LANGINFO *>(&SPATR);
  318.     HRESULT hr = g_App.m_pDvdCore->m_pIDvdI2->GetSubpictureAttributes(ulStream, &SPATR);
  319.     ASSERT(SUCCEEDED(hr)) ;
  320.     return g_App.m_pLangLookup->GetLangString(SPATR.Language, buffer, iBufLen) ;
  321. }
  322.  
  323.  
  324.  
  325.  
  326. //------------------------------------------------------------------------------
  327. // CAudioLangDlg
  328. //------------------------------------------------------------------------------
  329.  
  330.  
  331. //------------------------------------------------------------------------------
  332. // Name: CAudioLangDlg::CAudioLangDlg()
  333. // Desc: This is the CAudioLangDlg Constructor.
  334. //------------------------------------------------------------------------------
  335.  
  336. CAudioLangDlg::CAudioLangDlg(HINSTANCE hInstance, HWND hWnd):
  337.     m_hInstance(hInstance), m_hWnd(hWnd)
  338. {
  339.     DbgLog((LOG_TRACE, 5, TEXT("CAudioLangDlg::CAudioLangDlg()"))) ;
  340. }
  341.  
  342.  
  343. //------------------------------------------------------------------------------
  344. // Name: CAudioLangDlg::~CAudioLangDlg()
  345. // Desc: This is the CAudioLangDlg destructor.
  346. //------------------------------------------------------------------------------
  347.  
  348. CAudioLangDlg::~CAudioLangDlg()
  349. {
  350.     DbgLog((LOG_TRACE, 5, TEXT("CAudioLangDlg::~CAudioLangDlg()"))) ;
  351. }
  352.  
  353.  
  354. //------------------------------------------------------------------------------
  355. // Name: CAudioLangDlg::DoModal()
  356. // Desc: This method creates the dialog box and handles its return value.
  357. //------------------------------------------------------------------------------
  358.  
  359. bool CAudioLangDlg::DoModal()
  360. {
  361.     DbgLog((LOG_TRACE, 5, TEXT("CAudioLangDlg::DoModal()"))) ;
  362.  
  363.     int retVal;
  364.     retVal = DialogBoxParam(m_hInstance, MAKEINTRESOURCE(IDD_AUDIODLG), m_hWnd, 
  365.         (DLGPROC) CAudioLangDlg::AudioDlgProc, reinterpret_cast<LPARAM>(this));
  366.     if (TRUE == retVal)
  367.     {
  368.         return true;
  369.     }
  370.     else return false;
  371. }
  372.  
  373.  
  374. //------------------------------------------------------------------------------
  375. // Name: CAudioLangDlg::AudioDlgProc()
  376. // Desc: This is the Dialog MessageProc for the audio language selection
  377. //       dialog.
  378. //------------------------------------------------------------------------------
  379.  
  380. BOOL CALLBACK CAudioLangDlg::AudioDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  381. {
  382.     static CAudioLangDlg * pThis; 
  383.  
  384.     switch (message)
  385.     {
  386.     case WM_INITDIALOG:
  387.         pThis = reinterpret_cast<CAudioLangDlg *>(lParam); // get a pointer to the calling object
  388.         if (0 < pThis->MakeAudioStreamList(hDlg, IDC_AUDIOLANG))
  389.             return TRUE;
  390.         else
  391.         {
  392.              EndDialog(hDlg, FALSE);
  393.             return FALSE;
  394.         }
  395.  
  396.     case WM_COMMAND:
  397.         switch (LOWORD(wParam))
  398.         {
  399.         case IDOK:
  400.             {
  401.             HRESULT hr;
  402.  
  403.             // Set the audio stream specific by the user
  404.             LONG lStream;
  405.             lStream = SendDlgItemMessage(hDlg, IDC_AUDIOLANG, CB_GETCURSEL, 
  406.                 static_cast<WPARAM>(0), static_cast<LPARAM>(0));
  407.             if (CB_ERR == lStream)
  408.                 DbgLog((LOG_ERROR, 1, 
  409.                 TEXT("WARNING: Couldn't get selected Audio stream ID (Error %d)"), lStream)) ;
  410.             else
  411.             {
  412.                 pThis->m_ulAudioStream = lStream;
  413.                 hr = g_App.m_pDvdCore->m_pIDvdC2->SelectAudioStream(pThis->m_ulAudioStream,
  414.                     0, NULL) ;
  415.                 ASSERT(SUCCEEDED(hr)) ;
  416.             }
  417.  
  418.             } // end of case brackets
  419.  
  420.             EndDialog(hDlg, TRUE);
  421.             return TRUE;
  422.  
  423.         case IDCANCEL:
  424.             EndDialog(hDlg, FALSE);
  425.             return TRUE;
  426.         }
  427.         break;
  428.     }
  429.     return FALSE;
  430. }
  431.  
  432.  
  433. //------------------------------------------------------------------------------
  434. // Name: CAudioLangDlg::MakeAudioStreamList()
  435. // Desc: This method will populate our dialog box and return the number of audio
  436. //       streams on this disc.  We do some extra work to get around LCID limitations
  437. //       on Win9x.
  438. //------------------------------------------------------------------------------
  439.  
  440. int CAudioLangDlg::MakeAudioStreamList(HWND hDlg, int iListID)
  441. {
  442.     DbgLog((LOG_TRACE, 5, TEXT("CAudioLangDlg::MakeAudioStreamList(0x%lx, %d)"), 
  443.         hDlg, iListID)) ;
  444.  
  445.     if (Uninitialized == g_App.m_pDvdCore->GetState())
  446.     {
  447.         DbgLog((LOG_ERROR, 0, TEXT("WARNING: DvdCore not initialized yet!"))) ;
  448.         return 0 ;
  449.     }
  450.  
  451.     // First clear the list box of all audio stream names
  452.     SendDlgItemMessage(hDlg, iListID, CB_RESETCONTENT, static_cast<WPARAM>(0), 
  453.         static_cast<LPARAM>(0)) ;
  454.  
  455.     // Find out how many audio streams are there and what's the current lang.
  456.     // This is our chance to find out if someone changed the audio lang through 
  457.     // DVD menu so that we can synch up our audio stream value now.
  458.     HRESULT hr = g_App.m_pDvdCore->m_pIDvdI2->GetCurrentAudio(&m_ulNumLang, &m_ulAudioStream) ;
  459.     if (FAILED(hr))
  460.     {
  461.         MessageBox(m_hWnd, TEXT("Not ready to find language information"), TEXT("Warning"), MB_OK) ;
  462.         return 0 ;
  463.     }
  464.  
  465.     LCID lcid;
  466.     TCHAR szLang[50];
  467.  
  468.     // Add all of the streams to the dialog box
  469.     for (ULONG ulStream = 0; ulStream < m_ulNumLang; ulStream++)
  470.     {
  471.         if (FAILED(g_App.m_pDvdCore->m_pIDvdI2->GetAudioLanguage(ulStream, &lcid)))
  472.         {
  473.             DbgLog((LOG_ERROR, 0, TEXT("WARNING: GetAudioLanguage Failed!"))) ;
  474.             return 0 ;
  475.         }
  476.  
  477.         if (0 == lcid || 0 == GetLocaleInfo(lcid, LOCALE_SLANGUAGE, 
  478.             szLang, sizeof(szLang)/sizeof(szLang[0]))) 
  479.         // 0 is the failure code for GetLocaleInfo
  480.         {
  481.             GetAudioLang(ulStream, szLang, sizeof(szLang));
  482.         }
  483.  
  484.         // Add the language to the listbox
  485.         SendDlgItemMessage(hDlg, iListID, CB_ADDSTRING, static_cast<WPARAM>(0),
  486.             reinterpret_cast<LPARAM>(static_cast<PVOID>(szLang)));
  487.     }
  488.  
  489.     // set the current stream as the selected item
  490.     if (m_ulNumLang > 0) // if there are any streams
  491.     {
  492.         int iRes = SendDlgItemMessage(hDlg, iListID, CB_SETCURSEL, 
  493.             static_cast<WPARAM>(m_ulAudioStream), static_cast<LPARAM>(0)) ;
  494.         if (CB_ERR == iRes)
  495.             DbgLog((LOG_ERROR, 1, 
  496.             TEXT("WARNING: Couldn't set %ld as selected audio stream ID (Error %d)"),
  497.             m_ulAudioStream, iRes)) ;
  498.     }
  499.  
  500.     return m_ulNumLang;
  501. }
  502.  
  503.  
  504. //------------------------------------------------------------------------------
  505. // Name: CAudioLangDlg::GetAudioLang()
  506. // Desc: This method gets the LCID language code and looks up the audio
  507. //       language based on that.  This is to get around problems with Win95 where
  508. //       not all LCID's are recognized.
  509. //------------------------------------------------------------------------------
  510.  
  511. bool CAudioLangDlg::GetAudioLang(ULONG ulStream, TCHAR * buffer, int iBufLen)
  512. {
  513.     DbgLog((LOG_TRACE, 5, TEXT("CAudioLangDlg::GetAudioLang()"))) ;
  514.  
  515.     DVD_AudioAttributes AudATR ;
  516.     LANGINFO * pSPATR = reinterpret_cast<LANGINFO *>(&AudATR);
  517.     HRESULT hr = g_App.m_pDvdCore->m_pIDvdI2->GetAudioAttributes(ulStream, &AudATR);
  518.     ASSERT(SUCCEEDED(hr)) ;
  519.     return g_App.m_pLangLookup->GetLangString(AudATR.Language, buffer, iBufLen) ;
  520. }
  521.  
  522.  
  523.  
  524.  
  525. //------------------------------------------------------------------------------
  526. // CAngleDlg
  527. //------------------------------------------------------------------------------
  528.  
  529.  
  530. //------------------------------------------------------------------------------
  531. // Name: CAngleDlg::CAngleDlg()
  532. // Desc: This method is the constructor for CAngleDlg
  533. //------------------------------------------------------------------------------
  534.  
  535. CAngleDlg::CAngleDlg(HINSTANCE hInstance, HWND hWnd):
  536.     m_hInstance(hInstance), m_hWnd(hWnd)
  537. {
  538.     DbgLog((LOG_TRACE, 5, TEXT("CAngleDlg::CAngleDlg()"))) ;
  539. }
  540.  
  541.  
  542. //------------------------------------------------------------------------------
  543. // Name: CAngleDlg::CAngleDlg()
  544. // Desc: This method is the destructor for CAngleDlg
  545. //------------------------------------------------------------------------------
  546.  
  547. CAngleDlg::~CAngleDlg()
  548. {
  549.     DbgLog((LOG_TRACE, 5, TEXT("CAngleDlg::~CAngleDlg()"))) ;
  550. }
  551.  
  552.  
  553. //------------------------------------------------------------------------------
  554. // Name: CAngleDlg::DoModal()
  555. // Desc: This method creates the dialog and handles its return value.
  556. //------------------------------------------------------------------------------
  557.  
  558. bool CAngleDlg::DoModal()
  559. {
  560.     DbgLog((LOG_TRACE, 5, TEXT("CAngleDlg::DoModal()"))) ;
  561.  
  562.     int retVal;
  563.     retVal = DialogBoxParam(m_hInstance, MAKEINTRESOURCE(IDD_ANGLEDLG), m_hWnd, 
  564.         (DLGPROC) CAngleDlg::AngleDlgProc, reinterpret_cast<LPARAM>(this));
  565.     if (TRUE == retVal)
  566.     {
  567.         return true;
  568.     }
  569.     else return false;
  570. }
  571.  
  572.  
  573. //------------------------------------------------------------------------------
  574. // Name: CAngleDlg::AngleDlgProc()
  575. // Desc: This is the Dialog MessageProc for the angle selection dialog
  576. //------------------------------------------------------------------------------
  577.  
  578. BOOL CALLBACK CAngleDlg::AngleDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  579. {
  580.     static CAngleDlg * pThis; 
  581.  
  582.     switch (message)
  583.     {
  584.     case WM_INITDIALOG:
  585.         pThis = reinterpret_cast<CAngleDlg *>(lParam); // get a pointer to the calling object
  586.         if (0 < pThis->MakeAngleList(hDlg, IDC_ANGLE))
  587.             return TRUE;
  588.         else
  589.         {
  590.              EndDialog(hDlg, FALSE);
  591.             return FALSE;
  592.         }
  593.  
  594.     case WM_COMMAND:
  595.         switch (LOWORD(wParam))
  596.         {
  597.         case IDOK:
  598.             {
  599.             HRESULT hr;
  600.  
  601.             // Set the Angle specific by the user
  602.             LONG lAngle;
  603.             lAngle = SendDlgItemMessage(hDlg, IDC_ANGLE, CB_GETCURSEL, 
  604.                 static_cast<WPARAM>(0), static_cast<LPARAM>(0));
  605.             lAngle += 1; // angles start count at 1 so we have to account for that
  606.             if (CB_ERR == lAngle)
  607.                 DbgLog((LOG_ERROR, 1, 
  608.                 TEXT("WARNING: Couldn't get selected angle ID (Error %d)"), lAngle)) ;
  609.             else
  610.             {
  611.                 pThis->m_ulAngle = lAngle;
  612.                 hr = g_App.m_pDvdCore->m_pIDvdC2->SelectAngle(pThis->m_ulAngle, 0, NULL) ;
  613.                 ASSERT(SUCCEEDED(hr)) ;
  614.             }
  615.  
  616.             } // end of case brackets
  617.  
  618.             EndDialog(hDlg, TRUE);
  619.             return TRUE;
  620.  
  621.         case IDCANCEL:
  622.             EndDialog(hDlg, FALSE);
  623.             return TRUE;
  624.         }
  625.         break;
  626.     }
  627.     return FALSE;
  628. }
  629.  
  630.  
  631. //------------------------------------------------------------------------------
  632. // Name: CAngleDlg::MakeAngleList()
  633. // Desc: This method will populate our dialog box and return the number of angles
  634. //       on this disc.
  635. //------------------------------------------------------------------------------
  636.  
  637. int CAngleDlg::MakeAngleList(HWND hDlg, int iListID)
  638. {
  639.     DbgLog((LOG_TRACE, 5, TEXT("CAngleDlg::MakeAngleList(0x%lx, %d)"), 
  640.         hDlg, iListID)) ;
  641.  
  642.     if (Uninitialized == g_App.m_pDvdCore->GetState())
  643.     {
  644.         DbgLog((LOG_ERROR, 0, TEXT("WARNING: DvdCore not initialized yet!"))) ;
  645.         return 0 ;
  646.     }
  647.  
  648.     // First clear the list box of all angle names
  649.     SendDlgItemMessage(hDlg, iListID, CB_RESETCONTENT, static_cast<WPARAM>(0), 
  650.         static_cast<LPARAM>(0)) ;
  651.  
  652.     // Find out how many angles are there and what is the current angle.
  653.     // This is our chance to find out if someone changed the angle through 
  654.     // DVD menu so that we can synch up our angle value now.
  655.     HRESULT hr = g_App.m_pDvdCore->m_pIDvdI2->GetCurrentAngle(&m_ulNumAngle, &m_ulAngle) ;
  656.     if (FAILED(hr))
  657.     {
  658.         MessageBox(m_hWnd, TEXT("Not ready to find angle information"), TEXT("Warning"), MB_OK) ;
  659.         return 0 ;
  660.     }
  661.  
  662.     TCHAR szAngle[50];
  663.  
  664.     // Add all of the angles to the dialog box
  665.     for (ULONG ulAngle = 1; ulAngle <= m_ulNumAngle; ulAngle++) // angles start at 1
  666.     {
  667.         wsprintf(szAngle, TEXT("Angle %u"), ulAngle);
  668.  
  669.         // Add the language to the listbox
  670.         SendDlgItemMessage(hDlg, iListID, CB_ADDSTRING, static_cast<WPARAM>(0),
  671.             reinterpret_cast<LPARAM>(static_cast<PVOID>(szAngle)));
  672.     }
  673.  
  674.     // set the current angle as the selected item
  675.     if (m_ulNumAngle > 0) // if there are any angles
  676.     {
  677.         // angles start at 1 so we have to subtract 1 from the angle number to match the 
  678.         // correct angle
  679.         int iRes = SendDlgItemMessage(hDlg, iListID, CB_SETCURSEL, 
  680.             static_cast<WPARAM>(m_ulAngle - 1), static_cast<LPARAM>(0)) ;  
  681.         if (CB_ERR == iRes)
  682.             DbgLog((LOG_ERROR, 1, 
  683.             TEXT("WARNING: Couldn't set %ld as selected angle ID (Error %d)"),
  684.             m_ulAngle, iRes)) ;
  685.     }
  686.  
  687.     return m_ulNumAngle;
  688. }
  689.  
  690.  
  691.  
  692.  
  693. //------------------------------------------------------------------------------
  694. // CChapterDlg
  695. //------------------------------------------------------------------------------
  696.  
  697.  
  698. //------------------------------------------------------------------------------
  699. // Name: CChapterDlg::CChapterDlg()
  700. // Desc: This method is the constructor for CChapterDlg
  701. //------------------------------------------------------------------------------
  702.  
  703. CChapterDlg::CChapterDlg(HINSTANCE hInstance, HWND hWnd):
  704.     m_hInstance(hInstance), m_hWnd(hWnd)
  705. {
  706.     DbgLog((LOG_TRACE, 5, TEXT("CChapterDlg::CChapterDlg()"))) ;
  707.  
  708.     m_ulChapter = 1; // default value
  709. }
  710.  
  711.  
  712. //------------------------------------------------------------------------------
  713. // Name: CChapterDlg::CChapterDlg()
  714. // Desc: This method is the destructor for CChapterDlg
  715. //------------------------------------------------------------------------------
  716.  
  717. CChapterDlg::~CChapterDlg()
  718. {
  719.     DbgLog((LOG_TRACE, 5, TEXT("CChapterDlg::~CChapterDlg()"))) ;
  720. }
  721.  
  722.  
  723. //------------------------------------------------------------------------------
  724. // Name: CChapterDlg::DoModal()
  725. // Desc: This method creates the dialog and handles its return value.
  726. //------------------------------------------------------------------------------
  727.  
  728. bool CChapterDlg::DoModal()
  729. {
  730.     DbgLog((LOG_TRACE, 5, TEXT("CChapterDlg::DoModal()"))) ;
  731.  
  732.     int retVal;
  733.     retVal = DialogBoxParam(m_hInstance, MAKEINTRESOURCE(IDD_CHAPTERDLG), m_hWnd, 
  734.         (DLGPROC) CChapterDlg::ChapterDlgProc, reinterpret_cast<LPARAM>(this));
  735.     if (TRUE == retVal)
  736.     {
  737.         return true;
  738.     }
  739.     else return false;
  740. }
  741.  
  742.  
  743. //------------------------------------------------------------------------------
  744. // Name: CChapterDlg::ChapterDlgProc()
  745. // Desc: This is the Dialog MessageProc for the Chapter selection dialog
  746. //------------------------------------------------------------------------------
  747.  
  748. BOOL CALLBACK CChapterDlg::ChapterDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  749. {
  750.     static CChapterDlg * pThis; 
  751.  
  752.     switch (message)
  753.     {
  754.     case WM_INITDIALOG:
  755.         {
  756.         pThis = reinterpret_cast<CChapterDlg *>(lParam); // get a pointer to the calling object
  757.         
  758.         // set default value
  759.         TCHAR buf[10];
  760.         wsprintf(buf, TEXT("%u"), pThis->m_ulChapter); 
  761.         SetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf);
  762.         
  763.         //set up spin control
  764.         HWND hEBox = GetDlgItem(hDlg, IDC_PLAYCHAPTER);
  765.         CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 
  766.             10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 999, 1, 1);
  767.         return TRUE;
  768.         }
  769.  
  770.     case WM_COMMAND:
  771.         switch (LOWORD(wParam))
  772.         {
  773.         case IDOK:
  774.             {
  775.             // Set the Chapter specified by the user
  776.             TCHAR buf[10];
  777.             GetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf, sizeof(buf)/sizeof(TCHAR));
  778.             //sscanf(buf, TEXT("%u"), pThis->m_ulChapter);
  779.             pThis->m_ulChapter = _ttoi(buf);
  780.             } // end of case brackets
  781.  
  782.             EndDialog(hDlg, TRUE);
  783.             return TRUE;
  784.  
  785.         case IDCANCEL:
  786.             EndDialog(hDlg, FALSE);
  787.             return TRUE;
  788.         }
  789.         break;
  790.     }
  791.     return FALSE;
  792. }
  793.  
  794.  
  795.  
  796.  
  797. //------------------------------------------------------------------------------
  798. // CTitleDlg
  799. //------------------------------------------------------------------------------
  800.  
  801.  
  802. //------------------------------------------------------------------------------
  803. // Name: CTitleDlg::CTitleDlg()
  804. // Desc: This method is the constructor for CTitleDlg
  805. //------------------------------------------------------------------------------
  806.  
  807. CTitleDlg::CTitleDlg(HINSTANCE hInstance, HWND hWnd):
  808.     m_hInstance(hInstance), m_hWnd(hWnd)
  809. {
  810.     DbgLog((LOG_TRACE, 5, TEXT("CTitleDlg::CTitleDlg"))) ;
  811.  
  812.     m_ulTitle = 1; // default value
  813.     m_ulChapter = 1; 
  814. }
  815.  
  816.  
  817. //------------------------------------------------------------------------------
  818. // Name: CTitleDlg::CTitleDlg()
  819. // Desc: This method is the destructor for CTitleDlg
  820. //------------------------------------------------------------------------------
  821.  
  822. CTitleDlg::~CTitleDlg()
  823. {
  824.     DbgLog((LOG_TRACE, 5, TEXT("CTitleDlg::~CTitleDlg"))) ;
  825. }
  826.  
  827.  
  828. //------------------------------------------------------------------------------
  829. // Name: CTitleDlg::DoModal()
  830. // Desc: This method creates the dialog and handles its return value.
  831. //------------------------------------------------------------------------------
  832.  
  833. bool CTitleDlg::DoModal()
  834. {
  835.     DbgLog((LOG_TRACE, 5, TEXT("CTitleDlg::DoModal"))) ;
  836.  
  837.     int retVal;
  838.     retVal = DialogBoxParam(m_hInstance, MAKEINTRESOURCE(IDD_TITLEDLG), m_hWnd, 
  839.         (DLGPROC) CTitleDlg::TitleDlgProc, reinterpret_cast<LPARAM>(this));
  840.     if (TRUE == retVal)
  841.     {
  842.         return true;
  843.     }
  844.     else return false;
  845. }
  846.  
  847.  
  848. //------------------------------------------------------------------------------
  849. // Name: CTitleDlg::TitleDlgProc()
  850. // Desc: This is the Dialog MessageProc for the Title selection dialog
  851. //------------------------------------------------------------------------------
  852.  
  853. BOOL CALLBACK CTitleDlg::TitleDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  854. {
  855.     static CTitleDlg * pThis; 
  856.  
  857.     switch (message)
  858.     {
  859.     case WM_INITDIALOG:
  860.         {
  861.         pThis = reinterpret_cast<CTitleDlg *>(lParam); // get a pointer to the calling object
  862.         
  863.         // set default values
  864.         TCHAR buf[10];
  865.         wsprintf(buf, TEXT("%u"), pThis->m_ulTitle); 
  866.         SetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf);
  867.         wsprintf(buf, TEXT("%u"), pThis->m_ulChapter); 
  868.         SetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf);
  869.         
  870.         //set up spin control
  871.         HWND hEBox = GetDlgItem(hDlg, IDC_PLAYCHAPTER);
  872.         CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 
  873.             10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 999, 1, 1);
  874.         hEBox = GetDlgItem(hDlg, IDC_PLAYTITLE);
  875.         CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 
  876.             10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 99, 1, 1);
  877.         return TRUE;
  878.         }
  879.  
  880.     case WM_COMMAND:
  881.         switch (LOWORD(wParam))
  882.         {
  883.         case IDOK:
  884.             {
  885.             // Set the Title specified by the user
  886.             TCHAR buf[10];
  887.             GetDlgItemText(hDlg, IDC_PLAYCHAPTER, buf, sizeof(buf)/sizeof(TCHAR));
  888.             pThis->m_ulChapter = _ttoi(buf);
  889.             GetDlgItemText(hDlg, IDC_PLAYTITLE, buf, sizeof(buf)/sizeof(TCHAR));
  890.             pThis->m_ulTitle = _ttoi(buf);
  891.             } // end of case brackets
  892.  
  893.             EndDialog(hDlg, TRUE);
  894.             return TRUE;
  895.  
  896.         case IDCANCEL:
  897.             EndDialog(hDlg, FALSE);
  898.             return TRUE;
  899.         }
  900.         break;
  901.     }
  902.     return FALSE;
  903. }
  904.  
  905.  
  906.  
  907.  
  908. //------------------------------------------------------------------------------
  909. // CTimeDlg
  910. //------------------------------------------------------------------------------
  911.  
  912.  
  913. //------------------------------------------------------------------------------
  914. // Name: CTimeDlg::CTimeDlg()
  915. // Desc: This method is the constructor for CTimeDlg
  916. //------------------------------------------------------------------------------
  917.  
  918. CTimeDlg::CTimeDlg(HINSTANCE hInstance, HWND hWnd):
  919.     m_hInstance(hInstance), m_hWnd(hWnd)
  920. {
  921.     DbgLog((LOG_TRACE, 5, TEXT("CTimeDlg::CTimeDlg"))) ;
  922.  
  923.     ZeroMemory(&m_Time, sizeof(m_Time));
  924. }
  925.  
  926.  
  927. //------------------------------------------------------------------------------
  928. // Name: CTimeDlg::CTimeDlg()
  929. // Desc: This method is the destructor for CTimeDlg
  930. //------------------------------------------------------------------------------
  931.  
  932. CTimeDlg::~CTimeDlg()
  933. {
  934.     DbgLog((LOG_TRACE, 5, TEXT("CTimeDlg::~CTimeDlg"))) ;
  935. }
  936.  
  937.  
  938. //------------------------------------------------------------------------------
  939. // Name: CTimeDlg::DoModal()
  940. // Desc: This method creates the dialog and handles its return value.
  941. //------------------------------------------------------------------------------
  942.  
  943. bool CTimeDlg::DoModal()
  944. {
  945.     DbgLog((LOG_TRACE, 5, TEXT("CTimeDlg::DoModal"))) ;
  946.  
  947.     int retVal;
  948.     retVal = DialogBoxParam(m_hInstance, MAKEINTRESOURCE(IDD_TIMEDLG), m_hWnd, 
  949.         (DLGPROC) CTimeDlg::TimeDlgProc, reinterpret_cast<LPARAM>(this));
  950.     if (TRUE == retVal)
  951.     {
  952.         return true;
  953.     }
  954.     else return false;
  955. }
  956.  
  957.  
  958. //------------------------------------------------------------------------------
  959. // Name: CTimeDlg::TimeDlgProc()
  960. // Desc: This is the Dialog MessageProc for the Time selection dialog
  961. //------------------------------------------------------------------------------
  962.  
  963. BOOL CALLBACK CTimeDlg::TimeDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  964. {
  965.     static CTimeDlg * pThis; 
  966.  
  967.     switch (message)
  968.     {
  969.     case WM_INITDIALOG:
  970.         {
  971.         pThis = reinterpret_cast<CTimeDlg *>(lParam); // get a pointer to the calling object
  972.         
  973.         // set default values
  974.         TCHAR buf[10];
  975.         wsprintf(buf, TEXT("%u"), pThis->m_Time.bHours); 
  976.         SetDlgItemText(hDlg, IDC_HOURS, buf);
  977.         wsprintf(buf, TEXT("%u"), pThis->m_Time.bMinutes); 
  978.         SetDlgItemText(hDlg, IDC_MINUTES, buf);
  979.         wsprintf(buf, TEXT("%u"), pThis->m_Time.bSeconds); 
  980.         SetDlgItemText(hDlg, IDC_SECONDS, buf);
  981.         
  982.         //set up spin controls
  983.         HWND hEBox = GetDlgItem(hDlg, IDC_HOURS);
  984.         CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 
  985.             10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 99, 0, 
  986.             pThis->m_Time.bHours);
  987.         hEBox = GetDlgItem(hDlg, IDC_MINUTES);
  988.         CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 
  989.             10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 60, 0, 
  990.             pThis->m_Time.bMinutes);
  991.         hEBox = GetDlgItem(hDlg, IDC_SECONDS);
  992.         CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_SETBUDDYINT | UDS_ALIGNRIGHT, 
  993.             10, 10, 50, 50, hDlg, ID_SPINCONTROL, pThis->m_hInstance, hEBox, 60, 0, 
  994.             pThis->m_Time.bSeconds);
  995.         return TRUE;
  996.         }
  997.  
  998.     case WM_COMMAND:
  999.         switch (LOWORD(wParam))
  1000.         {
  1001.         case IDOK:
  1002.             {
  1003.             // Set the Time specified by the user
  1004.             TCHAR buf[10];
  1005.             GetDlgItemText(hDlg, IDC_HOURS, buf, sizeof(buf)/sizeof(TCHAR));
  1006.             pThis->m_Time.bHours = (BYTE) _ttoi(buf);
  1007.             GetDlgItemText(hDlg, IDC_MINUTES, buf, sizeof(buf)/sizeof(TCHAR));
  1008.             pThis->m_Time.bMinutes = (BYTE) _ttoi(buf);
  1009.             GetDlgItemText(hDlg, IDC_SECONDS, buf, sizeof(buf)/sizeof(TCHAR));
  1010.             pThis->m_Time.bSeconds = (BYTE) _ttoi(buf);
  1011.             } // end of case brackets
  1012.  
  1013.             EndDialog(hDlg, TRUE);
  1014.             return TRUE;
  1015.  
  1016.         case IDCANCEL:
  1017.             EndDialog(hDlg, FALSE);
  1018.             return TRUE;
  1019.         }
  1020.         break;
  1021.     }
  1022.     return FALSE;
  1023. }
  1024.  
  1025.  
  1026.  
  1027.  
  1028. //------------------------------------------------------------------------------
  1029. // CKaraokeDlg
  1030. //------------------------------------------------------------------------------
  1031.  
  1032.  
  1033. //------------------------------------------------------------------------------
  1034. // Name: CKaraokeDlg::CKaraokeDlg()
  1035. // Desc: This method is the constructor for CKaraokeDlg
  1036. //------------------------------------------------------------------------------
  1037.  
  1038. CKaraokeDlg::CKaraokeDlg(HINSTANCE hInstance, HWND hWnd):
  1039.     m_hInstance(hInstance), m_hWnd(hWnd)
  1040. {
  1041.     DbgLog((LOG_TRACE, 5, TEXT("CKaraokeDlg::CKaraokeDlg"))) ;
  1042.  
  1043.     //ZeroMemory(&m_Karaoke, sizeof(m_Karaoke));
  1044. }
  1045.  
  1046.  
  1047. //------------------------------------------------------------------------------
  1048. // Name: CKaraokeDlg::CKaraokeDlg()
  1049. // Desc: This method is the destructor for CKaraokeDlg
  1050. //------------------------------------------------------------------------------
  1051.  
  1052. CKaraokeDlg::~CKaraokeDlg()
  1053. {
  1054.     DbgLog((LOG_TRACE, 5, TEXT("CKaraokeDlg::~CKaraokeDlg"))) ;
  1055. }
  1056.  
  1057.  
  1058. //------------------------------------------------------------------------------
  1059. // Name: CKaraokeDlg::DoModal()
  1060. // Desc: This method establishes that there is karaoke data in the current audio
  1061. //       stream.  If there is, it populates the dialog box and displays it.  It also
  1062. //       handles the mixing.  In a real application, it might be better to have a function
  1063. //       in CDvdCore which does the mixing, but we will violate encapsulation here to
  1064. //       make it easier to understand.
  1065. //
  1066. //       This method mixes a given channel into both speakers.  This can be controlled on 
  1067. //       a per-speaker basis if so desired. 
  1068. //------------------------------------------------------------------------------
  1069.  
  1070. bool CKaraokeDlg::DoModal()
  1071. {
  1072.     DbgLog((LOG_TRACE, 5, TEXT("CKaraokeDlg::DoModal"))) ;
  1073.  
  1074.     // first we should make sure that there is Karaoke Data available
  1075.     HRESULT hr;
  1076.  
  1077.     DVD_AudioAttributes audioAtr;
  1078.     hr = g_App.m_pDvdCore->m_pIDvdI2->GetAudioAttributes(DVD_STREAM_DATA_CURRENT, &audioAtr);
  1079.     if (FAILED(hr))
  1080.     {
  1081.         MessageBox(m_hWnd, TEXT("GetAudioAttributes Failed"), TEXT("Error!"), MB_OK);
  1082.         return false;
  1083.     }
  1084.  
  1085.     if( DVD_AudioMode_Karaoke != audioAtr.AppMode ) 
  1086.     {
  1087.         MessageBox(m_hWnd, TEXT("There is no Karaoke Data In This Audio Stream"), 
  1088.             TEXT("Error!"), MB_OK);
  1089.         return false;
  1090.     }
  1091.  
  1092.     // if we get here, we are in a karaoke section
  1093.     DVD_KaraokeAttributes karaokeAtr;
  1094.     hr = g_App.m_pDvdCore->m_pIDvdI2->GetKaraokeAttributes(DVD_STREAM_DATA_CURRENT, &karaokeAtr );
  1095.     if (FAILED(hr))
  1096.     {
  1097.         MessageBox(m_hWnd, TEXT("GetKaraokeAttributes Failed"), TEXT("Error!"), MB_OK);
  1098.         return false;
  1099.     }
  1100.  
  1101.     // assign names to the various channels.  Channels 0 and 1 are restricted
  1102.     m_pszChannel2 = KaraokeAsStr(karaokeAtr.wChannelContents[2]);
  1103.     m_pszChannel3 = KaraokeAsStr(karaokeAtr.wChannelContents[3]);
  1104.     m_pszChannel4 = KaraokeAsStr(karaokeAtr.wChannelContents[4]);
  1105.  
  1106.     int retVal;
  1107.     retVal = DialogBoxParam(m_hInstance, MAKEINTRESOURCE(IDD_KARAOKEDLG), m_hWnd, 
  1108.         (DLGPROC) CKaraokeDlg::KaraokeDlgProc, reinterpret_cast<LPARAM>(this));
  1109.     if (FALSE == retVal)
  1110.     {
  1111.         return false;
  1112.     }
  1113.     // else the user clicked OK
  1114.  
  1115.     ULONG ulMixFlags = NULL; // Initialize the flags variable to be blank
  1116.     INT chkChannel2, chkChannel3, chkChannel4;
  1117.  
  1118.     chkChannel2 = SendDlgItemMessage(m_hWnd, IDC_CHANNEL2, BM_GETCHECK, 0, 0);
  1119.     chkChannel3 = SendDlgItemMessage(m_hWnd, IDC_CHANNEL3, BM_GETCHECK, 0, 0);
  1120.     chkChannel4 = SendDlgItemMessage(m_hWnd, IDC_CHANNEL4, BM_GETCHECK, 0, 0);
  1121.  
  1122.     if (BST_CHECKED == chkChannel2)
  1123.     {
  1124.         ulMixFlags |= DVD_Mix_3to0;
  1125.         ulMixFlags |= DVD_Mix_3to1;
  1126.     }
  1127.     if (BST_CHECKED == chkChannel3)
  1128.     {
  1129.         ulMixFlags |= DVD_Mix_4to0;
  1130.         ulMixFlags |= DVD_Mix_4to1;
  1131.     }
  1132.     if (BST_CHECKED == chkChannel4)
  1133.     {
  1134.         ulMixFlags |= DVD_Mix_Lto0;
  1135.         ulMixFlags |= DVD_Mix_Lto1;
  1136.     }
  1137.  
  1138.     hr = g_App.m_pDvdCore->m_pIDvdC2->SelectKaraokeAudioPresentationMode(ulMixFlags);
  1139.     if (FAILED(hr))
  1140.     {
  1141.         MessageBox(m_hWnd, TEXT("SelectKaraokeAudioPresentationMode Failed"), TEXT("Error!"), MB_OK);
  1142.         return false;
  1143.     }
  1144.     else return true;
  1145. }
  1146.  
  1147.  
  1148. //------------------------------------------------------------------------------
  1149. // Name: CKaraokeDlg::KaraokeDlgProc()
  1150. // Desc: This is the Dialog MessageProc for the Karaoke selection dialog
  1151. //------------------------------------------------------------------------------
  1152.  
  1153. BOOL CALLBACK CKaraokeDlg::KaraokeDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  1154. {
  1155.     static CKaraokeDlg * pThis; 
  1156.  
  1157.     switch (message)
  1158.     {
  1159.     case WM_INITDIALOG:
  1160.         {
  1161.         pThis = reinterpret_cast<CKaraokeDlg *>(lParam); // get a pointer to the calling object
  1162.         SetDlgItemText(hDlg, IDC_CHANNEL2, pThis->m_pszChannel2);
  1163.         SetDlgItemText(hDlg, IDC_CHANNEL3, pThis->m_pszChannel3);
  1164.         SetDlgItemText(hDlg, IDC_CHANNEL4, pThis->m_pszChannel4);
  1165.       return TRUE;
  1166.         }
  1167.  
  1168.     case WM_COMMAND:
  1169.         switch (LOWORD(wParam))
  1170.         {
  1171.         case IDOK:
  1172.             {
  1173.             } // end of case brackets
  1174.  
  1175.             EndDialog(hDlg, TRUE);
  1176.             return TRUE;
  1177.  
  1178.         case IDCANCEL:
  1179.             EndDialog(hDlg, FALSE);
  1180.             return TRUE;
  1181.         }
  1182.         break;
  1183.     }
  1184.     return FALSE;
  1185. }
  1186.  
  1187.  
  1188.